//package com.zhz.mall.common.xxljob;
//
//import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
//import com.zhz.mall.common.util.inet.InetUtils;
//import com.zhz.mall.common.util.inet.InetUtilsProperties;
//import lombok.Data;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import java.net.InetAddress;
//
///**
// * @author zhouhengzhe
// */
//@Slf4j
//@Data
//@Configuration
//@ConfigurationProperties(prefix = "xxl.job")
//public class XxlJobConfig {
//
//    private AdminProperties admin = new AdminProperties();
//    private XxlJobExecutor executor = new XxlJobExecutor();
//
//    @Data
//    public static class AdminProperties {
//
//        private String addresses;
//        private String accessToken;
//    }
//
//
//    @Data
//    public static class XxlJobExecutor {
//
//        private String appname;
//        private String ip;
//        private Integer port = 9999;
//        private String logPath;
//        private Integer logRetentionDays = 30;
//        private String address;
//
//    }
//
//    @Bean
//    public XxlJobSpringExecutor xxlJobExecutor(XxlJobConfig xxlJobConfig) {
//        log.info(">>>>>>>>>>> xxl-job config init.");
//        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
//        AdminProperties admin = xxlJobConfig.getAdmin();
//        xxlJobSpringExecutor.setAdminAddresses(admin.getAddresses());
//        xxlJobSpringExecutor.setAccessToken(admin.getAccessToken());
//
//        XxlJobExecutor executor = xxlJobConfig.getExecutor();
//        xxlJobSpringExecutor.setAppname(executor.appname);
//        xxlJobSpringExecutor.setAddress(executor.getAddress());
//        xxlJobSpringExecutor.setIp(executor.getIp());
//        if (StringUtils.isBlank(executor.getIp())) {
//            InetUtils inetUtils = new InetUtils(new InetUtilsProperties());
//            InetAddress nonLoopbackAddress = inetUtils.findFirstNonLoopbackAddress();
//            xxlJobSpringExecutor.setIp(nonLoopbackAddress.getHostAddress());
//        }
//
//        xxlJobSpringExecutor.setPort(executor.getPort());
//        xxlJobSpringExecutor.setLogPath(executor.getLogPath());
//        xxlJobSpringExecutor.setLogRetentionDays(executor.getLogRetentionDays());
//        return xxlJobSpringExecutor;
//    }
//
//
//}